
$(".logins").click(function(e){
    var username=$("#username").val();
    var password=$("#password").val();
    $.ajax({
        type:'POST',
        url:'http://localhost:8080/front/login',
        data:{"username":username,"password":password},
        success:function (data) {
            var Objdata=JSON.parse(data);
            $.cookie("name",Objdata.name);
            $.cookie("image",Objdata.image);
            console.log($.cookie("name"));
            $(".login-p").text($.cookie("name"));
            $('#myModal').modal('toggle');
            $(".email").css("display","none");
            window.location.reload()
        },error: function(XMLHttpRequest, textStatus, errorThrown) {
            alert(2+" "+XMLHttpRequest + " " + textStatus + " " + errorThrown)
        }
    });
}
)
$(".registers").click(
function (e) {
    var name=$("#name").val();
    var phone=$("#phone").val();
    var password=$("#passwords").val();
    $.ajax({
        url:'http://localhost:8080/front/register',
        type:'POST',
        data:{"name":name,"phone":phone,"password":password},
        success:function (data) {
            $('#myModal1').modal('toggle');
            if(data=="1"){
                alert("成功")
            }else{
                alert("失败")
            }

        }
    })
}
)

var vm=new Vue({
el:"#bs-example-navbar-collapse-1",
data:{
    name:$.cookie("name"),
    image:$.cookie("image")
}
})


new Vue({
    el:".contents",
    data(){
        return {
            recomlist:[]
        }
    },
    mounted:function(){
        this.alllist();
    },
    methods:{
        alllist:function () {
            axios.post('http://localhost:8080/front/recommend1').then(res=>res.data).then(data=>{
                this.recomlist=data;
            })
        }
    }
})